class Rational:
    def __init__(self,numberator = 1,denominator = 0):
        divisor = gcd(numberator,denominator)
        self.__numberator = (1 if denominator > 0 else -1) * int(numberator / divisor)
        self.__denominator = int(abs(denominator) / divisor)


    def __add__(self,secondRational):
        n = self.__numberator*secondRational[1] + self.__denominator*secondRational[0]
        d = self.__denominator * secondRational[1]
        return Rational(n,d)

    def __sub__(self, secondRational):
        n = self.__numberator*secondRational[1] - self.__denominator* secondRational[0]
        d = self.__denominator * secondRational[1]
        return Rational(n,d)


    def __mul__(self, other):
        n = self.__numberator * other[0]
        d = self.__denominator * other[1]
        return Rational(n,d)

    def __truediv__(self, other):
        n = self.__numberator * other[1]
        d = self.__numberator * other[0]
        return Rational(n,d)

    def __float__(self):

        return self.__numberator / self.__denominator

    def __int__(self):
        return int(self.__float__())

    def __str__(self):
        if self.__denominator == 1:
            return str(self.__numberator)
        else:
            return str(self.__numberator) + "/" + str(self.__denominator)

    def __lt__(self, other):
        return self.__cmp__(other) < 0

    def __cmp__(self, other):
        temp = self.__sub__(other)
        if temp[0] > 0:
            return 1


        elif temp[0] < 0:
            return -1
        else :
            return 0

    def __le__(self, other):
        return self.__cmp__(other) <=0
    def __gt__(self, other):
        return self.__cmp__(other) > 0
    def __ge__(self, other):
        return self.__cmp__(other) >= 0

    def __getitem__(self, item):
        if item == 0:
            return self.__numberator
        else:
            return self.__denominator

def gcd(n,d):
    n1 = abs(n)
    n2 = abs(d)
    gcd = 1
    k = 1
    while k <=n1 and k<=n2:
        if n1%k==0 and n2%k==0:
            gcd = k
        k+=1
    return gcd